<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<?php
if(!isset($_GET["action"])) {$action="";}else {$action = $_GET["action"];}
if(!isset($_GET["cb_naissance"])) {$cb_naissance="";}else {$cb_naissance = $_GET["cb_naissance"];}
/*
// autre écritures possibles
$action=isset($_GET["action"]) ? $_GET["action"]:"";
// ou encore
if (isset($_GET["action"])):
    $action = $_GET["action"];
else:
    $action = "";
endif;
 * */
 
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        // put your code here
        $tab[0]["nom"]="CAZENAVE";
        $tab[0]["prenom"]="Laura";
        $tab[0]["date_naissance"]="01/01/2010";
        $tab[1]["nom"]="JULY";
        $tab[1]["prenom"]="Anne";
        $tab[1]["date_naissance"]="02/02/2010";
        $tab[2]["nom"]="DUPONT";
        $tab[2]["prenom"]="Henri";
        $tab[2]["date_naissance"]="03/03/2010";
        $tab[3]["nom"]="MARTIN";
        $tab[3]["prenom"]="Sophie";
        $tab[3]["date_naissance"]="04/04/2010";
        $tab[4]["nom"]="JACKSON";
        $tab[4]["prenom"]="Mickael";
        $tab[4]["date_naissance"]="05/05/2010";
        
//        var_dump($tab);
        ?>
        
        <form id="form1" name="form1" action="" method="get">
                 <div>
                <select id="cb_naissance" name="cb_naissance" class="form-control">
                    <?php
                    for($x=0; $x<5;$x++) {
                    ?>
                    <option value="<?php echo $x; ?>"><?php echo $tab[$x]["nom"]."/".$tab[$x]["prenom"]; ?></option>
                    <?php
                    }
                    ?>
                </select>
            </div>
            <div>
<!--                <input type="submit" id='afficher' name="action" value="Afficher la date de naissance">-->
            <button type="submit" name="action" value="1">Afficher la date de naissance</button>
            </div>
            
<!--             <input type="hidden" name="action" value="1">   -->
            
            
            
        </form>
        
        <?php
         if($action==1) {  
        ?>
        <div><?php echo $tab[$cb_naissance]["nom"]." ".$tab[$cb_naissance]["prenom"]." ".$tab[$cb_naissance]["date_naissance"]; ?></div>
        <?php
        }
        ?>
    </body>
</html>
